<!DOCTYPE html>
<!--[if lt IE 7 ]> <html class="ie6"> <![endif]-->
<!--[if IE 7 ]>    <html class="ie7"> <![endif]-->
<!--[if IE 8 ]>    <html class="ie8"> <![endif]-->
<!--[if IE 9 ]>    <html class="ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!-->
<html>
<!--<![endif]-->

<head>
<meta charset="utf-8">
<title>系统界面</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="favicon.ico">
<!-- css styles -->
<link href="${contextPath}css/bootstrap.css" rel="stylesheet"><!--基本样式-->
<link href="${contextPath}css/style.css" rel="stylesheet"><!--样式-->
<link href="${contextPath}css/animate.min.css" rel="stylesheet">
<link href="${contextPath}css/animate.delay.css" rel="stylesheet"><!--图片动画-->
<link href="${contextPath}css/font-awesome.min.css" rel="stylesheet" ><!--字体图标-->
<link href="${contextPath}css/colorbox.css" rel="stylesheet" >
<!--[if IE 7]>
<link href="${contextPath}css/font-awesome-ie7.min.css" rel="stylesheet">
<![endif]-->
<script src="${contextPath}js/jquery-1.11.0.min.js"></script>
<script src="${contextPath}js/jquery-migrate-1.1.1.min.js"></script>
<script src="${contextPath}js/jquery.cookie.js"></script>

<script src="${contextPath}js/basic.js"></script>
</head>

<body class="loginbody">

<div class="loginwrapper animate1 bounceInDown">
	<div class="loginwrap zindex100 animate1 bounceInDown">
	<h1 class="logintitle"><span class="icon-user"></span> 用户登录 </h1>
		<form id="loginform" method="post" onsubmit="javascript:return false;">
			<div class="loginwrapperinner">
				<p class="animate4 bounceIn"><input type="text" id="email" name="email" value="XXX@jkq.gov.cn" placeholder="XXX@jkq.gov.cn"/></p>
				<p class="animate5 bounceIn"><input type="password" id="pwd" name="pwd" placeholder="密 码" /></p>
				<p class="animate6 bounceIn"><button class="btn btn-primary btn-block" id="loginBtn">登 录</button></p>
				<p class="animate7 fadeIn"><a href="demo.html"><span class="icon-question-sign icon-white"></span> 忘记密码?</a></p>
			</div><!--loginwrapperinner-->
		</form>
	</div>
</div><!--loginwrapper-->

<script type="text/javascript">
$(function(){
	var anievent = ($.browser.webkit)? 'webkitAnimationEnd' : 'animationend';
	$('.loginwrap').bind(anievent,function(){
		$(this).removeClass('animate2 bounceInDown');
	});
	
	$('#email, #pwd').focus(function(){
		if($(this).hasClass('error')) $(this).removeClass('error');
	});
	
	$('#loginBtn').click(function(){
		var email = $('#email');
		var pwd = $('#pwd');
		
		if(email == '' || pwd.val() == '') {
		
			if(email.val() == '') email.addClass('error'); else email.removeClass('error');
			if(pwd.val() == '') pwd.addClass('error'); else pwd.removeClass('error');
			
			if(!$.browser.msie) {
				$('.loginwrap').addClass('animate0 wobble').bind(anievent,function(){
					$(this).removeClass('animate0 wobble');
				});
			}
		} else {
			login(email.val(), pwd.val());
		}
	});
});



$(function () {
	var email = getCookie('email');
	var pwd = getCookie('pwd');
	if (null != email)
		$('#email').val(email);
	if (null != pwd)
		$('#pwd').val(pwd);
	
	if (!$('body').hasClass('no-animation')) {
		var timeout = 0;

		if ($('html').hasClass('csstransitions'))
			timeout = 750;

		$('.login-btn').mouseenter(function() {
			$('.left-door, .right-door, .login-btn').addClass('login-animate');
			setTimeout(function() {
				$('#login-container').fadeIn(1500);
				$('.login-btn .name').fadeOut(250, function() {
					$('.login-btn .square1, .login-btn .square2').fadeIn(750);
					$('#login-email').focus();});
				}, timeout);
		});
	}
});

function login(email, pwd) {
	var url = '${contextPath}bsLogin2.html?time=' + sys_get_time();
	var parm = {'email':email, 'pwd':pwd};
	$.ajax({type:'POST', url:url, data:parm,
		success : function(result) {
			if ('success' == result) {
				setCookie('email', email,365);
				setCookie('pwd', pwd,365);
				location.href = '${contextPath}main.html';
			}else if ('not_find' == result){
				alert('未找到该用户！');
			}else if ('pwd_error'){
				alert('密码错误！');
			}else if ('parameter_error' == result){
				alert('参数错误，请刷新页面后重试');
			}else if ('email_or_pwd_error' == result){
				alert('邮箱或密码错误');
			}else if ('no_any_rights' == result){
				alert('管理员还未给您赋予任何角色，请联系管理员');
			}else if ('deleted' == result) {
				alert('您已经被管理员禁用，请联系管理员');
			}else if ('exists'){
				alert('你的所属机构已经被删除，请联系管理员！');
			}
		}
	});
}

function setCookie(c_name, value,expiredays) {
		var exdate = new Date()
		exdate.setDate(exdate.getDate()
				+ expiredays)
		document.cookie = c_name
				+ "="
				+ escape(value)
				+ ((expiredays == null) ? "" : ";expires="+ exdate.toGMTString())
	}

	function getCookie(c_name) {
		if (document.cookie.length > 0) {
			c_start = document.cookie
					.indexOf(c_name + "=")
			if (c_start != -1) {
				c_start = c_start
						+ c_name.length + 1
				c_end = document.cookie.indexOf(";", c_start)
				if (c_end == -1)
					c_end = document.cookie.length
				return unescape(document.cookie.substring(c_start,c_end))
			}
		}
		return ""
	}
</script>
</body>
</html>
